import Vue from 'vue';
import Raven from 'raven-js';
import RavenVue from 'raven-js/plugins/vue';
import Login from '../login/index'

export default {
  Ravens: function (err) {
    console.log('asdasdasda')
    Raven
      .config('https://9352f91c539f42ba8802d31cf8acaab5@sentry.qingclass.com/4', {
        autoBreadcrumbs: {
          xhr: true,
          console: true
        },
        release: 'first'
      })
      .addPlugin(RavenVue, Vue)
      .install()
    Raven.setTagsContext({
      user_id: Login.oauth_token.user_id !== '-1' ? '未登录' : Login.oauth_token.user_id
    })
    Raven.setUserContext({
      id: Login.oauth_token.user_id || '-1',
    })
    window.onerror = function (e) {
      Raven.captureException(e)
    }
    Vue.config.errorHandler = (err, vm, info) => {
      Raven.captureException(err)
    }
  }
}
